$(function () {
    $("#gys_lj_id").xyljcombobox($("#jyjgId").val(), '0', 'true', {
        onSelect:function (data) {
            $("#gyg_sy").html(data['sy']);
            $("#gys_xy").html(data['xy']);
            var syNum = data['sy'].toString().split(",").length;
            var xyNum = data['xy'].toString().split(",").length;
            if (syNum > xyNum) {
                sy_init();
            } else if (syNum < xyNum) {
                xy_init();
            } else {
                sy_init();
                xy_init();
            }
        }
    });


});

//上游-加载
function sy_init() {
    $("#sy_show").show();
    var $form = $("#lj_gysForm");
    var strSyId = $form.find("[idVal='ljLs_sy_id']").attr("data-value");
    var strSyJc = $form.find("[idVal='ljLs_sy_id']").attr("data-text");
    var arrSySelect = [];
    if (strSyJc) {
        var arrSyId = strSyId.split(",");
        var arrSyJc = strSyJc.split(",");
        if (strSyJc != "") {
            for (var i = 0; i < arrSyId.length; i++) {
                arrSySelect.push({id:arrSyId[i], jc:arrSyJc[i]})
            }
        }
    }
    $form.find("[idVal='ljLs_sy_id']").qyjgwin({
        selected:arrSySelect,
        multiple:true
    });
}

//下游-加载
function xy_init() {
    $("#xy_show").show();
    var $form = $("#lj_gysForm");
    var strXyId = $form.find("[idVal='ljLs_xy_id']").attr("data-value");
    var strXyJc = $form.find("[idVal='ljLs_xy_id']").attr("data-text");
    var arrXySelect = [];
    if (strXyJc) {
        var arrXyId = strXyId.split(",");
        var arrXyJc = strXyJc.split(",");
        if (strXyJc != "") {
            for (var i = 0; i < arrXyId.length; i++) {
                arrXySelect.push({id:arrXyId[i], jc:arrXyJc[i]})
            }
        }
    }
    $form.find("[idVal='ljLs_xy_id']").qyjgwin({
        selected:arrXySelect,
        multiple:true
    });
}
